import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver=webdriver.Firefox()
#百度首页
driver.get('https://www.baidu.com/')
driver.maximize_window()
#输入搜索内容
driver.find_element(By.XPATH,'//*[@id="chat-textarea"]').send_keys('耳机')
time.sleep(3)
#点击搜索
driver.find_element(By.ID,'chat-submit-button').click()
time.sleep(3)
#滚动到底部
driver.switch_to.default_content()
time.sleep(3)
#翻到第3页
driver.switch_to.frame('3')
time.sleep(2)